Resources
Installation
Install via Node.js:
npm install --global npmCheck installation:
npm --versionUsage
Initialize a new project:
npm initInstall a package:
npm install <package-name>Install a package as a development dependency:
npm install --save-dev <package-name>Install a package globally:
npm install --global <package-name>Update a package:
npm update <package-name>Remove a package:
npm uninstall <package-name>Commands
npm init: Initialize a new project.npm install <package>: Install a package.npm install --save-dev <package>: Install a package as a development dependency.npm install --global <package>: Install a package globally.npm update <package>: Update a package.npm uninstall <package>: Remove a package.
Example
npm install lodash
npm install --save-dev jest
npm install --global nodemon
npm update lodash
npm uninstall lodashConfiguration
Create a package.json file:
npm init --yesSet the registry:
npm config set registry https://registry.npmjs.org/Check the registry:
npm config get registryScripts
Add a script to package.json:
"scripts": {
"start": "node index.js"
}Run a script:
npm run startVersioning
Check the version of a package:
npm show <package-name> versionCheck outdated packages:
npm outdatedUpdate all packages:
npm updatePublishing
Login to NPM:
npm loginPublish a package:
npm publishUpdate the package version:
npm version <update_type>Troubleshooting
Clear the cache:
npm cache clean --forceCheck for vulnerabilities:
npm auditFix vulnerabilities:
npm audit fix